package com.handy.database.demo;

//import java.util.Date;

import com.handy.database.DBUtil;


public class DBUtilDemo {
	
	public static void main(String[] args) {
		DBUtil dbUtil = DBUtil.getInstance();
		
		String dataSourceName = "jdbc/basic";
		String username = "he";
		String password = "h2009e";
		String host = "202.103.25.191";
		String sid = "orayw";
		String url = "jdbc:oracle:thin:@" + host + ":1521:" + sid;
		
		dbUtil.createJNDI(dataSourceName, DBUtil.DB_DRIVER_ORACLE, username, password, url);
		dbUtil.setDataSourceName(dataSourceName);
		
//		String sql = "insert into test (id,cid,title,cdate)values(test_seq.nextval,1,'测试1',sysdate)";
//		dbUtil.update(null, sql);
		
		String sql = "insert into test (id,cid,title,cdate)values(?,?,?,to_date(?,'yyyy-mm-dd'))";
		Object[] params = {"30","4","测试2","2009-10-10"};
		dbUtil.update(null, sql, params);
		
	
		
		
		
		
		
		
		
		
		
		
//		String sql = "select count(*) from a";
//		
//		String temp = du.getSampleStringValue(null, sql);
//		log.info(temp);

//		String sql = "select ID,USERNUMBER from a where rownum<10";
//		int cols = 2;
//		int[] lobs = {0,0};
//		//ArrayList<String[]> _temp = du.getRsToObjList("jdbc/basic",sql, cols, lobs);
//		ArrayList<String[]> _temp = du.getRsToObjList("jdbc/basic",sql, cols, lobs , new LinkedList<Object>());
//		for (String[] _rec:_temp){
//			System.out.println(_rec[0]+"  "+_rec[1]);
//		}
		
//		LinkedList<Object> params = new LinkedList<Object>();
//		params.add("世界真美好！");
//		params.add(new Integer(20));
//		int i = 1;
//		for (java.util.Iterator<Object> iter = params.iterator();iter.hasNext();i++){
//			Object _value = iter.next();
//			if (_value instanceof String){
//				log.info(i+":字符串->"+(String)_value);
//			}else if (_value instanceof Integer){
//				log.info(i+":整  数->"+((Integer)_value).intValue());
//			}
//		}
	}
}
